import { request } from '@/utils/request';

const Api = {
    adminUserList: '/admin/user/list',
    userList: '/app/user/list',
};

/**
 * 分页查询管理员用户
 * @param data
 */
export function getAdminUserList(data: any) {
    return request.post({
        data,
        url: Api.adminUserList,
    });
}
/**
 * 分页查询普通用户
 * @param data
 */
export function getUserList(data: any) {
    return request.post({
        data,
        url: "/app/user/list",
    });
}

/**
 * 删除用户
 * @param data
 */
export function deleteUserById(userId: any) {
    return request.delete({
        url: `/admin/user/${userId}`,
    });
}
/**
 * 添加用户
 * @param data
 */
export function addUser(user: any) {
    return request.post({
        url: `/admin/user/`,
        data: user,
    });
}
/**
 * 添加普通用户
 * @param data
 */
export function addRegularUser(user: any) {
    return request.post({
        url: `/app/user/`,
        data: user,
    });
}
/**
 * 根据id查询用户信息
 * @param data
 */
export function getUserById(id: any) {
    return request.get({
        url: `/admin/user/`,
        params: {
            userId: id,
        },
    });
}
/**
 * 根据id封禁解封用户
 * @param data
 */
export function blockedAndUnseal(userId: any) {
    return request.put({
        url: `/admin/user/blockedAndUnseal/${userId}`,
    });
}
/**
 * 根据id修改用户信息
 * @param data
 */
export function updateUserById(user: any) {
    return request.put({
        url: `/admin/user/`,
        data: user,
    });
}

/**
 * 获取权限列表
 */
export function getPermissionList() {
    return request.get({
        url: '/admin/role/permissions/list',
    });
}

/**
 * 获取登录用户的信息
 */
export function getUserInfo() {
    return request.get({
        url: '/admin/user/getUserInfo',
    });
}
/**
 * 获取登录用户的权限信息
 */
export function getUserPermissions() {
    return request.get({
        url: '/admin/user/getPermsAndRoles',
    });
}

/**
 * 用户退出登录
 */
export function logout() {
    return request.get({
        url: '/admin/user/logout',
    });
}
